import java.util.Arrays;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/8/23 21:41
 */

public class Solution {
    public boolean checkInclusion(String s1, String s2) {
        int len1 = s1.length(), len2 = s2.length();
        if (len1 > len2) {
            return false;
        }

        int[] count1 = new int[26];
        int[] count2 = new int[26];

        // 初始化s1和s2的窗口频率
        for (int i = 0; i < len1; i++) {
            count1[s1.charAt(i) - 'a']++;
            count2[s2.charAt(i) - 'a']++;
        }

        // 检查初始窗口是否匹配
        if (Arrays.equals(count1, count2)) {
            return true;
        }

        for (int i = len1; i < len2; i++) {
            // 移除窗口最左边的字符
            count2[s2.charAt(i - len1) - 'a']--;
            // 加入右边的字符
            count2[s2.charAt(i) - 'a']++;
            if (Arrays.equals(count1, count2)) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s1 = in.nextLine();
            String s2 = in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.checkInclusion(s1, s2));
        }
    }
}